package game.main;

import javafx.scene.media.AudioClip;

import java.net.URL;

public class Sound {

    private AudioClip audio;
    private final URL[] soundURL = new URL[20];
    public Sound() {
        soundURL[0] = getClass().getResource("/sound/BlueBoyAdventure.wav");
        soundURL[1] = getClass().getResource("/sound/coin.wav");
        soundURL[2] = getClass().getResource("/sound/powerup.wav");
        soundURL[3] = getClass().getResource("/sound/unlock.wav");
        soundURL[4] = getClass().getResource("/sound/fanfare.wav");
        soundURL[5] = getClass().getResource("/sound/hitmonster.wav");
        soundURL[6] = getClass().getResource("/sound/receivedamage.wav");
        soundURL[7] = getClass().getResource("/sound/attacks.wav");
        soundURL[8] = getClass().getResource("/sound/levelup.wav");
        soundURL[9] = getClass().getResource("/sound/cursor.wav");
        soundURL[10] = getClass().getResource("/sound/burning.wav");
        soundURL[11] = getClass().getResource("/sound/cuttree.wav");
        soundURL[12] = getClass().getResource("/sound/gameover.wav");
        soundURL[13] = getClass().getResource("/sound/stairs.wav");
        soundURL[14] = getClass().getResource("/sound/sleep.wav");
    }


    public void playLoopMusic(int i) {
        audio = new AudioClip(soundURL[i].toString());
        audio.setCycleCount(AudioClip.INDEFINITE);
        audio.play();
    }

    public void stopMusic() {
        if (audio!=null){
            audio.stop();
        }
    }

    public void playSE(int i) {
        AudioClip audioClip = new AudioClip(soundURL[i].toString());
        audioClip.play();
    }
}
